<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/assets/cashier/css/main.css"/>
    <link rel="stylesheet" href="/assets/cashier/css/iconfont.css">
    <script type="text/javascript" src="/assets/cashier/js/jquery-1.11.3.js"></script>
    <script type="text/javascript" src="/assets/cashier/js/main.js"></script>
    <title>登录</title>
    <style>
        .language{
            width:100%;
            height: 40px;
            line-height: 40px;
            margin-top: 20px;
            font-size: 20px;
            color: #d1d1d1;
        }
        .language .lang{
            display: inline-block;
            width:48%;
            text-align: center;
            cursor: pointer;
        }
        .language span.active{
            color: #fff;
        }
        .login-input{
        	width: 315px;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <div class="login-box">
               <div class="login-head">日出宝收银系统</div>
               <div class="input-box">
                   <span class="iconfont icon-gerenzhongxin"></span>
                   <input type="text" class="login-input" id="user" name="user" placeholder="请输入你的账号" >
               </div>
               <div class="input-box">
                   <span class="iconfont icon-suo"></span>
                   <input type="password" class="login-input" id="pass" name="password" placeholder="请输入你的密码" >
               </div>
               <div class="login-btn">登录</div>
                <div class="language">
                    <span class="lang chinese active" data-lang="chinese">中文</span>
                    <span class="lang english" data-lang="english">ENGLISH</span>
                </div>
        </div>
    </div>
    <div class="tip hide"></div>
    <script type="text/javascript">
        $(function () {
            var langs='chinese';
            localStorage.setItem('SITE_LANG',langs);
            $('.lang').click(function () {
                $(this).addClass("active").siblings().removeClass('active');
                langs=$(this).attr('data-lang');
                localStorage.setItem('SITE_LANG',langs);
                if(langs == 'chinese'){
                   $('#user').attr('placeholder','请输入你的账号');
                   $('#pass').attr('placeholder','请输入你的密码');
                   $('.login-btn').html('登录');
               }else{
                   $('#user').attr('placeholder','username');
                   $('#pass').attr('placeholder','password');
                   $('.login-btn').html('login');
               }
                
            });
            $('.login-btn').click(function () {
                var username=$('#user').val();
                var password=$('#pass').val();
                var url=urlHead+'/login';

                if(!username){
                    tip(lang('LOGIN_NO_USER'));
                    return;
                }
                if(!username){
                    tip('LOGIN_NO_PASSWORD');
                    return;
                }
                var data={
                    username:username,
                    password:password,
                    lang:langs
                };
                $.ajax({
                    type:"POST",
                    dataType:'json',
                    data:data,
                    url:url,
                    success:function (json) {
                    	 localStorage.setItem('CASHIER',username);
                    	$.ajax({
						    type:'GET',
						    data:'',
						    url:urlHead+'//goods/basic',
						    dataType:'json',
						    success:function (json) {
						      	localStorage.setItem('SITE_CONFIG',JSON.stringify(json));   
                                window.location.href=urlHead+'/index/index/index';  
						    }
						})
                        
                    }
                })
            });
           
             
        })

    </script>
</body>
</html>